#ifndef DELEGATE_H
#define DELEGATE_H
 
#include <QStyledItemDelegate>
#include <QItemDelegate>

/////////////////////////////////////////////////////////////
// ComboBoxDelegate

class ComboBoxDelegate : public QStyledItemDelegate
{
    Q_OBJECT
 
public:
    ComboBoxDelegate(QObject *parent);
    ~ComboBoxDelegate();
 
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                                        const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
                                    const QModelIndex &index) const;

};

/////////////////////////////////////////////////////////////
// SpinBoxDelegate

class SpinBoxDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    SpinBoxDelegate(QObject *parent = 0);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override;

    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
                      const QModelIndex &index) const override;

    void updateEditorGeometry(QWidget *editor,
        const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
 
/////////////////////////////////////////////////////////////
// ReadOnlyDelegate

class ReadOnlyDelegate: public QItemDelegate
{

public:
    ReadOnlyDelegate(QWidget *parent = NULL):QItemDelegate(parent)
    {}

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override //final
    {
        Q_UNUSED(parent)
        Q_UNUSED(option)
        Q_UNUSED(index)
        return NULL;
    }
};

#endif // DELEGATE_H
